package org.example.comment.controlleradvice;

import org.example.comment.common.APIResponse;
import org.example.comment.common.ResponseCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public APIResponse handleException(Exception e) {
        return new APIResponse(ResponseCode.INTERNAL_SERVER_ERROR, "内部服务器错误: " + e.getMessage());
    }
}
